home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 026-050 / scopedisk28 / qmouse12 / qmouse.asm < prev    next >
Assembly Source File  |  1995-03-18  |  30KB  |  1,169 lines

  1. ;                           QMouse 1.2  by Lyman Epp
  2. ;
  3. ;        Another "Mouse Accelerator???"  What for?  It seems that all the
  4. ;        other mouse accelerators have been written in "C".  This is okay,
  5. ;        but the programs are 10-30K.  This mouse accelerator is written
  6. ;        in assembler and contains most of the features of the others, but
  7. ;        the program size is less than 3K bytes!  Also, the source is
  8. ;        included so that you can add more features (please send me a copy
  9. ;        if you do.)  QMouse stands for "Quick Mouse."
  10. ;
  11. ;        This is being distributed as ShareWare.  If you think that QMouse
  12. ;        is useful, please send $10.  Your response will insure the release
  13. ;        of more quality programs for your Amiga!  Programs already in the
  14. ;        works include: a disk based print spooler, a window dump that
  15. ;        converts the window bitmap back to text, and more.  Be sure to
  16. ;        check out the latest shareware version of QView.
  17. ;
  18. ;        The latest version of QMouse can always be found on the Wind
  19. ;        Dragon Inn BBS, (402)-291-8053.
  20. ;
  21. ;                Lyman R. Epp
  22. ;                10072 Wirt Plaza #15
  23. ;                Omaha, Nebraska 68134
  24.  
  25.  
  26.          SECTION  text,CODE
  27.  
  28.          INCLUDE  "exec/execbase.i"
  29.          INCLUDE  "exec/memory.i"
  30.          INCLUDE  "libraries/dosextens.i"
  31.          INCLUDE  "devices/input.i"
  32.          INCLUDE  "graphics/gfxbase.i"
  33.          INCLUDE  "graphics/copper.i"
  34.          INCLUDE  "hardware/custom.i"
  35.          INCLUDE  "hardware/dmabits.i"
  36.          INCLUDE  "intuition/intuition.i"
  37.          INCLUDE  "intuition/intuitionbase.i"
  38.  
  39.  
  40. RAW_M               EQU     $37
  41. RAW_ESCAPE          EQU     $45
  42.  
  43. CLOCK_WIDTH         EQU     44
  44.  
  45. FLAGB_BLANK         EQU     0
  46. FLAGB_POINTEROFF    EQU     1
  47. FLAGB_NO_AMIGA_M    EQU     2
  48. FLAGB_CLOCK         EQU     3
  49. FLAGB_SUNMOUSE      EQU     4
  50. FLAGB_CLICKBACK     EQU     5
  51.  
  52. POSTB_BLANK         EQU     0
  53. POSTB_UNBLANK       EQU     1
  54. POSTB_NEWCLI        EQU     2
  55. POSTB_TIMER         EQU     3
  56. POSTB_SHUFFLE       EQU     4
  57. POSTB_FRONT         EQU     5
  58. POSTB_BACK          EQU     6
  59. POSTB_ACTIVATE      EQU     7
  60. POSTB_QUIT          EQU     8
  61.  
  62.  
  63.         STRUCTURE work,0
  64.  
  65.         APTR    dosBase
  66.         APTR    gfxBase
  67.         APTR    layersBase
  68.         APTR    intuitionBase
  69.  
  70.         APTR    parmAddr
  71.  
  72.         APTR    qmouseTask
  73.         ULONG   qmouseSignal
  74.         UWORD   qmousePost
  75.         UBYTE   qmouseFlag
  76.         UBYTE   filler
  77.  
  78.         UWORD   mouseAccel
  79.         UWORD   accelThresh
  80.         UWORD   pointerSecs
  81.         UWORD   screenSecs
  82.         UWORD   numClicks
  83.  
  84.         APTR    front
  85.         APTR    back
  86.         APTR    activate
  87.  
  88.         APTR    clockWindow
  89.         APTR    blankScreen
  90.         APTR    blankSprite
  91.         APTR    saveSprite
  92.         ULONG   nullHandle
  93.         ULONG   timerSec
  94.         UWORD   blankTimer
  95.         UWORD   pointerTimer
  96.         UWORD   clicksLeft
  97.         APTR    clickWindow
  98.         STRUCT  clickTime,8
  99.  
  100.         STRUCT  execCommand,100
  101.  
  102.         STRUCT  inputReqBlk,IOSTD_SIZE
  103.         STRUCT  handlerStuff,IS_SIZE
  104.  
  105.         LABEL   work_SIZEOF
  106.  
  107.  
  108.  
  109.         XREF    _AbsExecBase
  110.  
  111.  
  112. CALLSYS MACRO
  113.         XREF    _LVO\1
  114.         CALLLIB _LVO\1
  115.         ENDM
  116.  
  117. LINKSYS MACRO
  118.         XREF    _LVO\1
  119.         LINKLIB _LVO\1,\2
  120.         ENDM
  121.  
  122. ON_DISPLAY  MACRO
  123.         move.w  #BITSET!DMAF_RASTER,$dff000+dmacon
  124.         ENDM
  125.  
  126. OFF_DISPLAY  MACRO
  127.         move.w  #BITCLR!DMAF_RASTER,$dff000+dmacon
  128.         ENDM
  129.  
  130.  
  131.  
  132. QMouse:
  133.         move.l  _AbsExecBase,a6
  134.         move.l  #workarea,a5
  135.  
  136.         IFD     MANX
  137.         move.l  a5,a1
  138.         move.l  #(work_SIZEOF-1)/4,d1   ; round to the number of longs - 1 !!
  139. Clear_Mem:
  140.         clr.l   (a1)+                   ; manx doesn't set the length
  141.         dbf     d1,Clear_Mem            ; of the BSS hunk, so the loader
  142.         ENDC                            ; doesn't clear it !!!
  143.  
  144.         move.l  ThisTask(a6),qmouseTask(a5)
  145.         move.l  a0,parmAddr(a5)         ; save parm len/address
  146.  
  147.         lea     dosName(pc),a1          ; open "dos.library"
  148.         moveq   #LIBRARY_VERSION,d0
  149.         CALLSYS OpenLibrary
  150.         move.l  d0,dosBase(a5)
  151.         beq     abort
  152.  
  153.         lea     graphicsName(pc),a1     ; open "graphics.library"
  154.         moveq   #LIBRARY_VERSION,d0
  155.         CALLSYS OpenLibrary
  156.         move.l  d0,gfxBase(a5)
  157.         beq     abort
  158.  
  159.         lea     layersName(pc),a1       ; open "layers.library"
  160.         moveq   #LIBRARY_VERSION,d0
  161.         CALLSYS OpenLibrary
  162.         move.l  d0,layersBase(a5)
  163.         beq     abort
  164.  
  165.         lea     intuitionName(pc),a1    ; open "intuition.library"
  166.         moveq   #LIBRARY_VERSION,d0
  167.         CALLSYS OpenLibrary
  168.         move.l  d0,intuitionBase(a5)
  169.         beq     abort
  170.  
  171.         move.w  #3,mouseAccel(a5)       ; initialize the defaults
  172.         move.w  #3,accelThresh(a5)
  173.         move.w  #10,pointerSecs(a5)
  174.         move.w  #600,screenSecs(a5)
  175.         move.w  #2,numClicks(a5)
  176.         movem.l defaultCommand(pc),d0-d1
  177.         movem.l d0-d1,execCommand(a5)
  178.  
  179.         move.l  parmAddr(a5),a0         ; get parm len/address
  180.         bsr     ParseInput
  181.  
  182.         lea     qmousePortName(pc),a1
  183.         CALLSYS FindPort
  184.         tst.l   d0
  185.         bne     abort
  186.  
  187.         moveq   #12,d0                  ; minimum sprite size
  188.         move.l  #MEMF_CHIP!MEMF_CLEAR,d1
  189.         CALLSYS AllocMem                ; allocate working storage
  190.         move.l  d0,blankSprite(a5)
  191.         beq     abort
  192.         move.l  d0,a0
  193.         move.w  #$FF00,(a0)
  194.         move.w  #$FF00,2(a0)
  195.  
  196.         move.w  screenSecs(a5),blankTimer(a5)
  197.         move.w  pointerSecs(a5),pointerTimer(a5)
  198.  
  199.         lea     nullName(pc),a1
  200.         move.l  a1,d1
  201.         move.l  #MODE_NEWFILE,d2
  202.         LINKSYS Open,dosBase(a5)
  203.         move.l  d0,nullHandle(a5)
  204.         beq     abort
  205.  
  206.         move.l  qmouseTask(a5),a1
  207.         move.b  pr_MsgPort+MP_SIGBIT(a1),d1
  208.         moveq   #0,d0
  209.         bset    d1,d0
  210.         move.l  d0,qmouseSignal(a5)
  211.  
  212.         btst    #FLAGB_CLOCK,qmouseFlag(a5)
  213.         beq     Main_NoClock
  214.         lea     clockNewWindow(pc),a0
  215.         LINKSYS OpenWindow,intuitionBase(a5)
  216.         move.l  d0,clockWindow(a5)
  217.         beq     abort
  218.         bsr     Clock
  219. Main_NoClock:
  220.  
  221.         lea     qmousePortName(pc),a0
  222.         moveq   #0,d0
  223.         bsr     CreatePort
  224.         tst.l   d0
  225.         beq     abort
  226.  
  227.         lea     inputReqBlk(a5),a1
  228.         move.b  #NT_MESSAGE,LN_TYPE(a1)
  229.         move.w  #IOSTD_SIZE,MN_LENGTH(a1)
  230.         move.l  d0,MN_REPLYPORT(a1)
  231.  
  232.         lea     inputName(pc),a0
  233.         moveq   #0,d0
  234.         moveq   #0,d1
  235.         CALLSYS OpenDevice
  236.         tst.l   d0
  237.         bne     abort
  238.  
  239.         lea     MyHandler(pc),a1
  240.         lea     handlerStuff(a5),a0
  241.         move.b  #51,LN_PRI(a0)          ; before Intuition !!
  242.         move.l  a1,IS_CODE(a0)
  243.  
  244.         move.l  qmouseTask(a5),a1
  245.         moveq   #25,d0                  ; before input.device !!
  246.         CALLSYS SetTaskPri
  247.  
  248.         lea     inputReqBlk(a5),a1
  249.         move.l  a0,IO_DATA(a1)
  250.         move.w  #IND_ADDHANDLER,IO_COMMAND(a1)
  251.         CALLSYS DoIO
  252.  
  253. Main_Wait:
  254.         move.l  qmouseSignal(a5),d0
  255.         CALLSYS Wait
  256.         CALLSYS Forbid
  257.  
  258.         move.w  qmousePost(a5),d7
  259.         clr.w   qmousePost(a5)
  260.  
  261.         btst    #POSTB_BLANK,d7
  262.         beq     Main_Blank
  263.         bsr     BlankScreen
  264. Main_Blank:
  265.  
  266.         btst    #POSTB_UNBLANK,d7
  267.         beq     Main_Unblank
  268.         bsr     UnblankScreen
  269. Main_Unblank:
  270.  
  271.         btst    #POSTB_NEWCLI,d7
  272.         beq     Main_Newcli
  273.         bsr     NewCLI
  274. Main_Newcli:
  275.  
  276.         btst    #POSTB_TIMER,d7
  277.         beq     Main_Timer
  278.         bsr     Clock
  279. Main_Timer:
  280.  
  281.         btst    #POSTB_SHUFFLE,d7
  282.         beq     Main_Shuffle
  283.         move.l  intuitionBase(a5),a0
  284.         move.l  ib_FirstScreen(a0),a0
  285.         LINKSYS ScreenToBack,intuitionBase(a5)
  286. Main_Shuffle:
  287.  
  288.         btst    #POSTB_FRONT,d7
  289.         beq     Main_Front
  290.         move.l  front(a5),a0
  291.         LINKSYS WindowToFront,intuitionBase(a5)
  292. Main_Front:
  293.  
  294.         btst    #POSTB_BACK,d7
  295.         beq     Main_Back
  296.         move.l  back(a5),a0
  297.         LINKSYS WindowToBack,intuitionBase(a5)
  298. Main_Back:
  299.  
  300.         btst    #POSTB_ACTIVATE,d7
  301.         beq     Main_Active
  302.         move.l  activate(a5),a0
  303.         LINKSYS ActivateWindow,intuitionBase(a5)
  304. Main_Active:
  305.  
  306.         CALLSYS Permit
  307.  
  308.         btst    #POSTB_QUIT,d7
  309.         beq     Main_Wait
  310.  
  311.  
  312. Main_Quit:
  313.         lea     inputReqBlk(a5),a1
  314.         move.w  #IND_REMHANDLER,IO_COMMAND(a1)
  315.         CALLSYS DoIO
  316.  
  317.         lea     inputReqBlk(a5),a1
  318.         CALLSYS CloseDevice
  319.  
  320.         lea     inputReqBlk(a5),a1
  321.         move.l  MN_REPLYPORT(a1),d0
  322.         bsr     DeletePort
  323.  
  324.         bsr     PointerOn
  325.  
  326.  
  327. abort:
  328.         move.l  clockWindow(a5),d0
  329.         beq     Abort_NoWindow
  330.         move.l  d0,a0
  331.         LINKSYS CloseWindow,intuitionBase(a5)
  332. Abort_NoWindow:
  333.  
  334.         move.l  blankSprite(a5),d0
  335.         beq     Abort_NoBlankSprite
  336.         move.l  d0,a1
  337.         moveq   #12,d0
  338.         CALLSYS FreeMem
  339. Abort_NoBlankSprite:
  340.  
  341.         move.l  intuitionBase(a5),d0
  342.         beq     Abort_NoIntuitionLib
  343.         move.l  d0,a1
  344.         CALLSYS CloseLibrary
  345. Abort_NoIntuitionLib:
  346.  
  347.         move.l  layersBase(a5),d0
  348.         beq     Abort_NoLayersLib
  349.         move.l  d0,a1
  350.         CALLSYS CloseLibrary
  351. Abort_NoLayersLib:
  352.  
  353.         move.l  gfxBase(a5),d0
  354.         beq     Abort_NoGraphicsLib
  355.         move.l  d0,a1
  356.         CALLSYS CloseLibrary
  357. Abort_NoGraphicsLib:
  358.  
  359.         moveq   #0,d1                   ; initialize return code
  360.         LINKSYS Exit,dosBase(a5)        ; the SAFE way to return!
  361.  
  362.  
  363.  
  364. CreatePort:       ; ( Name:a0, Pri:d0 )
  365.         movem.l d2-d4/a2,-(sp)
  366.         move.l  a0,d3
  367.         move.b  d0,d4
  368.  
  369.         moveq   #-1,d0
  370.         CALLSYS AllocSignal
  371.         cmpi.b  #-1,d0
  372.         beq     CreatePort_Err
  373.         move.b  d0,d2
  374.  
  375.         moveq   #MP_SIZE,d0
  376.         move.l  #MEMF_PUBLIC!MEMF_CLEAR,d1
  377.         CALLSYS AllocMem
  378.         tst.l   d0
  379.         beq     CreatePort_Err
  380.         move.l  d0,a2
  381.  
  382.         move.l  d3,LN_NAME(a2)
  383.         move.b  d4,LN_PRI(a2)
  384.         move.b  #NT_MSGPORT,LN_TYPE(a2)
  385.         move.b  #PA_SIGNAL,MP_FLAGS(a2)
  386.         move.b  d2,MP_SIGBIT(a2)
  387.         move.l  ThisTask(a6),MP_SIGTASK(a2)
  388.  
  389.         tst.l   d3
  390.         beq     CreatePortNoName
  391.         move.l  a2,a1
  392.         CALLSYS AddPort
  393.         move.l  a2,d0
  394.         bra     CreatePort_End
  395.  
  396. CreatePortNoName:
  397.         lea     MP_MSGLIST(a2),a1
  398.         NEWLIST a1
  399.         move.l  a2,d0
  400.  
  401. CreatePort_End:
  402.         movem.l (sp)+,d2-d4/a2
  403.         rts
  404.  
  405. CreatePort_Err:
  406.         moveq   #0,d0
  407.         bra     CreatePort_End
  408.  
  409.  
  410.  
  411. DeletePort:       ; ( Port:d0 )
  412.         move.l  a2,-(sp)
  413.         move.l  d0,a2
  414.  
  415.         tst.l   LN_NAME(a2)
  416.         beq     DeletePort_NoName
  417.         move.l  a2,a1
  418.         CALLSYS RemPort
  419. DeletePort_NoName:
  420.  
  421.         move.b  MP_SIGBIT(a2),d0
  422.         CALLSYS FreeSignal
  423.  
  424.         move.l  a2,a1
  425.         moveq   #MP_SIZE,d0
  426.         CALLSYS FreeMem
  427.  
  428.         move.l  (sp)+,a2
  429.         rts
  430.  
  431.  
  432.  
  433. ParseInput:     ; ( CommandLine:a0, Length:d0 )
  434.         moveq   #0,d1                    ; reset quoted flag
  435. Parse_Loop:
  436.         move.b  (a0)+,d2
  437.         cmpi.b  #10,d2
  438.         beq     Parse_Done
  439.         cmpi.b  #'"',d2
  440.         beq     Parse_QuoteChar
  441.         cmpi.b  #'-',d2
  442.         beq     Parse_Option
  443.         cmpi.b  #' ',d2
  444.         beq     Parse_Loop
  445.         bra     ErrUsage
  446.  
  447. Parse_Done:
  448.         btst    #31,d1
  449.         bne     ErrUsage
  450.         rts
  451.  
  452. Parse_QuoteChar:
  453.         bset    #31,d1
  454.         bra     Parse_Loop
  455.  
  456. Parse_Option:
  457.         move.b  (a0)+,d2
  458.         or.b    #$20,d2                  ; force to lowercase
  459.         cmpi.b  #'a',d2                  ; Accel factor
  460.         beq     Parse_Acc
  461.         cmpi.b  #'b',d2                  ; click to back enabled
  462.         beq     Parse_ClickBack
  463.         cmpi.b  #'c',d2                  ; Clock enable
  464.         beq     Parse_Clock
  465.         cmpi.b  #'e',d2                  ; Execute command
  466.         beq     Parse_Exec
  467.         cmpi.b  #'k',d2                  ; number of clicks (to front)
  468.         beq     Parse_Klick
  469.         cmpi.b  #'m',d2                  ; Amiga-M disable
  470.         beq     Parse_Amiga_M
  471.         cmpi.b  #'p',d2                  ; Pointer Off seconds
  472.         beq     Parse_Pointer
  473.         cmpi.b  #'r',d2                  ; Sun Mouse enable?
  474.         beq     Parse_SunMouse
  475.         cmpi.b  #'s',d2                  ; Screen Blank seconds
  476.         beq     Parse_Screen
  477.         cmpi.b  #'t',d2                  ; Accel thresh-hold
  478.         beq     Parse_Thresh
  479.         cmpi.b  #'v',d2                  ; Stack Size value
  480.         beq     Parse_Stack
  481.         bra     ErrUsage
  482.  
  483. Parse_Next:
  484.         bclr    #31,d1
  485.         beq     Parse_Loop
  486.         cmpi.b  #'"',(a0)+
  487.         beq     Parse_Loop
  488.         bra     ErrUsage
  489.  
  490. Parse_Acc:
  491.         bsr     GetNumber
  492.         move.w  d0,mouseAccel(a5)
  493.         bra     Parse_Next
  494.  
  495. Parse_ClickBack:
  496.         bset    #FLAGB_CLICKBACK,qmouseFlag(a5)
  497.         bra     Parse_Next
  498.  
  499. Parse_Clock:
  500.         bset    #FLAGB_CLOCK,qmouseFlag(a5)
  501.         bsr     GetNumber
  502.         tst.w   d0
  503.         beq     Parse_Next
  504.         move.l  intuitionBase(a5),a1
  505.         move.l  ib_FirstScreen(a1),a1
  506.         move.w  sc_Width(a1),d1
  507.         sub.w   #CLOCK_WIDTH,d1
  508.         cmp.w   d1,d0
  509.         bgt     Parse_Next
  510.         lea     clockNewWindow(pc),a1
  511.         move.w  d0,nw_LeftEdge(a1)
  512.         bra     Parse_Next
  513.  
  514. Parse_Exec:
  515.         lea     execCommand(a5),a1
  516. Parse_ExecLoop:
  517.         move.b  (a0)+,d2
  518.         cmpi.b  #10,d2
  519.         beq     Parse_ExecDone
  520.         btst    #31,d1
  521.         bne     Parse_ExecQuoted
  522.         cmpi.b  #' ',d2                  ; end of the field?
  523.         bne     Parse_ExecMove
  524.         bra     Parse_ExecDone
  525. Parse_ExecQuoted:
  526.         cmpi.b  #'"',d2                  ; end of the field?
  527.         beq     Parse_ExecDone
  528. Parse_ExecMove:
  529.         move.b  d2,(a1)+
  530.         bra     Parse_ExecLoop
  531. Parse_ExecDone:
  532.         move.b  -(a0),d2                 ; point at char that terminated
  533.         clr.b   (a1)                     ; terminate the execute string
  534.         bra     Parse_Next
  535.  
  536. Parse_Klick:
  537.         bsr     GetNumber
  538.         move.w  d0,numClicks(a5)
  539.         bra     Parse_Next
  540.  
  541. Parse_Amiga_M:
  542.         bset    #FLAGB_NO_AMIGA_M,qmouseFlag(a5)
  543.         bra     Parse_Next
  544.  
  545. Parse_Pointer:
  546.         bsr     GetNumber
  547.         move.w  d0,pointerSecs(a5)
  548.         bra     Parse_Next
  549.  
  550. Parse_SunMouse:
  551.         bset    #FLAGB_SUNMOUSE,qmouseFlag(a5)
  552.         bra     Parse_Next
  553.  
  554. Parse_Screen:
  555.         bsr     GetNumber
  556.         move.w  d0,screenSecs(a5)
  557.         bra     Parse_Next
  558.  
  559. Parse_Thresh:
  560.         bsr     GetNumber
  561.         move.w  d0,accelThresh(a5)
  562.         bra     Parse_Next
  563.  
  564. Parse_Stack:
  565.         bsr     GetNumber
  566.         cmpi.l  #1800,d0
  567.         blt     ErrUsage
  568.         move.l  qmouseTask(a5),a1
  569.         move.l  pr_CLI(a1),a1
  570.         add.l   a1,a1                     ; convert that silly BPTR to ADDR
  571.         add.l   a1,a1
  572.         lsr.l   #2,d0
  573.         move.l  d0,cli_DefaultStack(a1)   ; and set the default stack size!
  574.         bra     Parse_Next
  575.  
  576.  
  577. GetNumber:
  578.         moveq   #0,d0
  579.         moveq   #0,d2
  580. GetNumberLoop:
  581.         move.b  (a0)+,d2
  582.         subi.b  #'0',d2
  583.         blt     GetNumber_Exit
  584.         cmpi.b  #9,d2
  585.         bgt     GetNumber_Exit
  586.         mulu    #10,d0
  587.         add.l   d2,d0
  588.         bra     GetNumberLoop
  589. GetNumber_Exit:
  590.         move.b  -(a0),d2                 ; point at char that terminated
  591.         rts
  592.  
  593.  
  594. ERR_USAGE        dc.b    $9b,'0;33mQMouse 1.2',$9b,'0m  by Lyman Epp',10
  595.                  dc.b    'Usage: QMouse -A# -B -C# -Ecommand -K# -M -P# -R -S# -T# -V#',10
  596. ERR_USAGE_SIZE   EQU     95               ; make it work with manx
  597.  
  598. ERR_FATAL        dc.b    'QMouse: Fatal error',10
  599. ERR_FATAL_SIZE   EQU     20               ; make it work with manx
  600.  
  601.         CNOP    0,2
  602.  
  603.  
  604. ErrUsage:
  605.         move.l  #ERR_USAGE,d2
  606.         move.l  #ERR_USAGE_SIZE,d3
  607.         bra     ErrDisplay
  608.  
  609. ErrFatal:
  610.         move.l  #ERR_FATAL,d2
  611.         move.l  #ERR_FATAL_SIZE,d3
  612.         bra     ErrDisplay
  613.  
  614. ErrDisplay:
  615.         LINKSYS Output,dosBase(a5)
  616.         move.l  d0,d1
  617.         LINKSYS Write,dosBase(a5)
  618.         bra     abort
  619.  
  620.  
  621.  
  622.  
  623. PointerOff:
  624.         move.l  gfxBase(a5),a1
  625.         move.l  gb_copinit(a1),a1
  626.         bset    #FLAGB_POINTEROFF,qmouseFlag(a5)
  627.         bne     PointerOffSkip
  628.         move.w  copinit_sprstrtup+2(a1),saveSprite+0(a5)
  629.         move.w  copinit_sprstrtup+6(a1),saveSprite+2(a5)
  630. PointerOffSkip:
  631.         move.w  blankSprite+0(a5),copinit_sprstrtup+2(a1)
  632.         move.w  blankSprite+2(a5),copinit_sprstrtup+6(a1)
  633.  
  634. PointerOff_End:
  635.         rts
  636.  
  637.  
  638.  
  639. PointerOn:
  640.         bclr    #FLAGB_POINTEROFF,qmouseFlag(a5)
  641.         beq     PointerOn_End
  642.  
  643.         move.l  gfxBase(a5),a1
  644.         move.l  gb_copinit(a1),a1
  645.         move.w  saveSprite+0(a5),copinit_sprstrtup+2(a1)
  646.         move.w  saveSprite+2(a5),copinit_sprstrtup+6(a1)
  647.  
  648. PointerOn_End:
  649.         rts
  650.  
  651.  
  652.  
  653. BlankScreen:
  654.         lea     blankNewScreen(pc),a0
  655.         LINKSYS OpenScreen,intuitionBase(a5)
  656.         move.l  d0,blankScreen(a5)
  657.         beq     Blank_End
  658.  
  659.         move.l  d0,a0
  660.         lea     sc_ViewPort(a0),a0
  661.         moveq   #0,d0
  662.         moveq   #0,d1
  663.         moveq   #0,d2
  664.         moveq   #0,d3
  665.         LINKSYS SetRGB4,gfxBase(a5)
  666.  
  667.         OFF_DISPLAY
  668.  
  669.         bset    #FLAGB_BLANK,qmouseFlag(a5)
  670.  
  671. Blank_End:
  672.         rts
  673.  
  674.  
  675.  
  676. UnblankScreen:
  677.         bclr    #FLAGB_BLANK,qmouseFlag(a5)
  678.         beq     Unblank_End
  679.  
  680.         move.l  blankScreen(a5),a0
  681.         LINKSYS CloseScreen,intuitionBase(a5)
  682.  
  683.         ON_DISPLAY
  684.  
  685. Unblank_End:
  686.         rts
  687.  
  688.  
  689.  
  690. NewCLI:
  691.         LINKSYS WBenchToFront,intuitionBase(a5)
  692.  
  693.         lea     execCommand(a5),a1
  694.         move.l  a1,d1
  695.         moveq   #0,d2
  696.         move.l  nullHandle(a5),d3
  697.         LINKSYS Execute,dosBase(a5)
  698.  
  699. NewCLI_End:
  700.         rts
  701.  
  702.  
  703.  
  704. Clock:
  705.         btst    #FLAGB_CLOCK,qmouseFlag(a5)
  706.         beq     Clock_End
  707.  
  708.         move.l  dosBase(a5),a0
  709.         move.l  dl_Root(a0),a0
  710.         move.l  rn_Time+ds_Minute(a0),d0
  711.  
  712.         divu    #60,d0
  713.         move.l  d0,d1                   ; save for calculating minutes
  714.  
  715.         cmpi.w  #12,d0
  716.         ble     Clock_NotPM
  717.         sub.w   #12,d0
  718. Clock_NotPM:
  719.         tst.w   d0
  720.         bne     Clock_NotMidnite
  721.         moveq   #12,d0
  722. Clock_NotMidnite:
  723.         ext.l   d0
  724.         divu    #10,d0
  725.         or.b    #'0',d0
  726.         cmpi.b  #'0',d0
  727.         bne     Clock_FirstCharOk
  728.         move.b  #' ',d0
  729. Clock_FirstCharOk:
  730.         lea     clockBuffer(pc),a0
  731.         move.b  d0,(a0)
  732.         swap    d0
  733.         or.b    #'0',d0
  734.         move.b  d0,1(a0)
  735.  
  736.         swap    d1
  737.         ext.l   d1
  738.         divu    #10,d1
  739.         or.b    #'0',d1
  740.         move.b  d1,3(a0)
  741.         swap    d1
  742.         or.b    #'0',d1
  743.         move.b  d1,4(a0)
  744.  
  745.         moveq   #':',d1
  746.         cmp.b   2(a0),d1
  747.         bne     Clock_FlipFlop
  748.         moveq   #' ',d1
  749. Clock_FlipFlop:
  750.         move.b  d1,2(a0)
  751.  
  752.         move.l  clockWindow(a5),a0
  753.         move.l  wd_RPort(a0),a0
  754.         lea     clockText(pc),a1
  755.         moveq   #0,d0
  756.         moveq   #0,d1
  757.         LINKSYS PrintIText,intuitionBase(a5)
  758.  
  759.         move.l  clockWindow(a5),a0
  760.         move.l  wd_RPort(a0),a1
  761.         move.l  rp_Layer(a1),a1
  762.         move.l  lr_ClipRect(a1),d0        ; are there any ClipRect structs ??
  763.         beq     Clock_End                 ; no, the clock isn't obscured!
  764.         move.l  d0,a1
  765.         tst.l   cr_Next(a1)               ; more than one ClipRect ??
  766.         bne     Clock_ToFront             ; yes, clock is obscured!
  767.         tst.l   cr_BitMap(a1)             ; was whole clock copied to BitMap ??
  768.         beq     Clock_End                 ; no, the clock isn't obscured!
  769. Clock_ToFront:
  770.         LINKSYS WindowToFront,intuitionBase(a5)
  771.  
  772. Clock_End:
  773.         rts
  774.  
  775.  
  776.  
  777. AccelMouse:
  778.         move.w  accelThresh(a5),d1
  779.         cmp.w   d1,d0
  780.         bgt     Accel_Yes
  781.         neg.w   d1
  782.         cmp.w   d1,d0
  783.         bge     Accel_No
  784. Accel_Yes:
  785.         sub.w   d1,d0
  786.         mulu    mouseAccel(a5),d0
  787.         add.w   d1,d0
  788. Accel_No:
  789.         rts
  790.  
  791.  
  792.  
  793. SunMouse:
  794.         move.l  a0,-(sp)
  795.         btst    #FLAGB_SUNMOUSE,qmouseFlag(a5)
  796.         beq     SunMouse_End
  797.  
  798.         bsr     WhichMouseLayer
  799.         tst.l   d0                        ; is pointer over a layer?
  800.         beq     SunMouse_End              ; no, don't bother!
  801.         move.l  d0,a1
  802.         move.l  lr_Window(a1),d0          ; is pointer over a window?
  803.         beq     SunMouse_End              ; no, don't bother!
  804.         move.l  intuitionBase(a5),a1
  805.         cmp.l   ib_ActiveWindow(a1),d0    ; is this window already active?
  806.         beq     SunMouse_End              ; yes, don't bother!
  807.  
  808.         move.l  d0,activate(a5)           ; activate this window
  809.         bset    #POSTB_ACTIVATE,d7
  810.  
  811. SunMouse_End:
  812.         move.l  (sp)+,a0
  813.         rts
  814.  
  815.  
  816.  
  817. CheckMouseClicks:
  818.         move.l  a0,-(sp)
  819.  
  820.         tst.w   numClicks(a5)             ; click to front enabled?
  821.         beq     Click_End
  822.  
  823.         bsr     WhichMouseLayer           ; check if pointer is over a layer
  824.         tst.l   d0
  825.         beq     Click_None
  826.         move.l  d0,a1
  827.         move.l  lr_Window(a1),d4          ; check if pointer is over a window
  828.         beq     Click_None
  829.         move.l  lr_ClipRect(a1),d0        ; is this window already up front?
  830.         beq     Click_None                ; yes, don't waste more time!
  831.         move.l  d0,a1
  832.         tst.l   cr_Next(a1)               ; is this window already up front?
  833.         beq     Click_None                ; yes, don't waste more time!
  834.         move.l  d4,a1
  835.         move.l  wd_Flags(a1),d0
  836.         and.w   #BACKDROP,d0              ; is this a BACKDROP window?
  837.         bne     Click_None                ; yes, don't waste more time!
  838.  
  839.         movem.l ie_TimeStamp(a0),d2-d3
  840.         cmp.l   clickWindow(a5),d4        ; same window as last click?
  841.         bne     Click_DiffWindow          ; no, reset clicks left
  842.         movem.l clickTime(a5),d0-d1       ; let intuition check if they
  843.         LINKSYS DoubleClick,intuitionBase(a5)  ; double clicked soon enough
  844.         tst.l   d0
  845.         bne     Click_CheckCount
  846. Click_DiffWindow:
  847.         move.w  numClicks(a5),clicksLeft(a5)
  848. Click_CheckCount:
  849.         movem.l d2-d3,clickTime(a5)
  850.         move.l  d4,clickWindow(a5)
  851.         sub.w   #1,clicksLeft(a5)
  852.         bne     Click_End
  853.         move.l  d4,front(a5)              ; bring this window to front
  854.         bset    #POSTB_FRONT,d7
  855. Click_None:
  856.         move.w  numClicks(a5),clicksLeft(a5)
  857.  
  858. Click_End:
  859.         move.l  (sp)+,a0
  860.         rts
  861.  
  862.  
  863.  
  864. WindowBack:
  865.         move.l  a0,-(sp)
  866.  
  867.         btst    #FLAGB_CLICKBACK,qmouseFlag(a5)
  868.         beq     Back_End
  869.  
  870.         bsr     WhichMouseLayer           ; check if pointer is over a layer
  871.         tst.l   d0
  872.         beq     Back_End
  873.         move.l  d0,a1
  874.         move.l  lr_Window(a1),d0          ; check if pointer is over a window
  875.         beq     Back_End
  876.         move.l  d0,a0
  877.         move.l  wd_Flags(a0),d0
  878.         and.w   #BACKDROP,d0              ; is this a BACKDROP window?
  879.         bne     Back_End                  ; yes, don't waste more time!
  880.  
  881.         move.l  a0,back(a5)               ; send this window to back
  882.         bset    #POSTB_BACK,d7
  883.  
  884. Back_End:
  885.         move.l  (sp)+,a0
  886.         rts
  887.  
  888.  
  889.  
  890. WhichMouseLayer:
  891.         movem.l d1-d3/a0-a3,-(sp)
  892.  
  893.         CALLSYS Forbid
  894.  
  895.         move.l  intuitionBase(a5),a3
  896.         move.l  ib_FirstScreen(a3),d0
  897.         beq     Layer_Exit
  898. Layer_Loop:
  899.         move.l  d0,a2
  900.         move.w  ib_MouseX(a3),d2
  901.         move.w  sc_ViewPort+vp_Modes(a2),d0
  902.         and.w   #V_HIRES,d0
  903.         bne     Layer_Hires
  904.         lsr.w   #1,d2
  905. Layer_Hires:
  906.         move.w  ib_MouseY(a3),d3
  907.         move.w  sc_ViewPort+vp_Modes(a2),d0
  908.         and.w   #V_LACE,d0
  909.         bne     Layer_Interlace
  910.         lsr.w   #1,d3
  911. Layer_Interlace:
  912.         lea     sc_LayerInfo(a2),a0
  913.         moveq   #0,d0
  914.         move.w  d2,d0
  915.         moveq   #0,d1
  916.         move.w  d3,d1
  917.         sub.w   sc_ViewPort+vp_DyOffset(a2),d1
  918.         LINKSYS WhichLayer,layersBase(a5)
  919.         tst.l   d0
  920.         bne     Layer_Exit
  921.         cmp.w   sc_ViewPort+vp_DyOffset(a2),d3
  922.         bge     Layer_Exit
  923.         move.l  sc_NextScreen(a2),d0
  924.         bne     Layer_Loop
  925.  
  926. Layer_Exit:
  927.         CALLSYS Permit
  928.  
  929.         movem.l (sp)+,d1-d3/a0-a3
  930.         rts
  931.  
  932.  
  933.  
  934. MyHandler:
  935.         movem.l d7/a0/a5,-(sp)
  936.         move.l  #workarea,a5
  937.         moveq   #0,d7
  938.  
  939. Handler_Loop:
  940.         cmpi.b  #IECLASS_TIMER,ie_Class(a0)
  941.         bne     Handler_NotTimer
  942.         bsr     TimerEvent
  943.         bra     Handler_NextEvent
  944.  
  945. Handler_NotTimer:
  946.         bsr     NotTimerEvent
  947.         cmpi.b  #IECLASS_RAWMOUSE,ie_Class(a0)
  948.         bne     Handler_NotMouse
  949.         bsr     MouseEvent
  950.         bra     Handler_NextEvent
  951.  
  952. Handler_NotMouse:
  953.         cmpi.b  #IECLASS_RAWKEY,ie_Class(a0)
  954.         bne     Handler_NextEvent
  955.         bsr     RawKeyEvent
  956.  
  957. Handler_NextEvent:
  958.         move.l  ie_NextEvent(a0),d0
  959.         move.l  d0,a0
  960.         bne     Handler_Loop
  961.  
  962.         move.w  d7,qmousePost(a5)
  963.         beq     Handler_End
  964.  
  965.         move.l  qmouseTask(a5),a1
  966.         move.l  qmouseSignal(a5),d0
  967.         LINKSYS Signal,_AbsExecBase
  968.  
  969. Handler_End:
  970.         move.l  (sp)+,d7
  971.         movem.l (sp)+,d0/a5
  972.         rts
  973.  
  974.  
  975.  
  976. TimerEvent:
  977.         btst    #FLAGB_POINTEROFF,qmouseFlag(a5)  ; Intuition will restore the
  978.         beq     Timer_PointerOK                   ; pointer--make sure its off!
  979.         bsr     PointerOff
  980. Timer_PointerOK:
  981.  
  982.         move.l  ie_TimeStamp(a0),d0
  983.         cmp.l   timerSec(a5),d0
  984.         beq     Timer_End
  985.  
  986.         move.l  d0,timerSec(a5)
  987.         bset    #POSTB_TIMER,d7
  988.  
  989.         tst.w   pointerSecs(a5)             ; pointer blank enabled?
  990.         beq     Timer_NotPointer
  991.         btst    #FLAGB_POINTEROFF,qmouseFlag(a5)
  992.         bne     Timer_NotPointer
  993.         subq.w  #1,pointerTimer(a5)
  994.         bne     Timer_NotPointer
  995.         bsr     PointerOff
  996. Timer_NotPointer:
  997.  
  998.         tst.w   screenSecs(a5)              ; Screen blank enabled?
  999.         beq     Timer_NotBlank
  1000.         btst    #FLAGB_BLANK,qmouseFlag(a5)
  1001.         bne     Timer_NotBlank
  1002.         subq.w  #1,blankTimer(a5)
  1003.         bne     Timer_NotBlank
  1004.  
  1005.         bset    #POSTB_BLANK,d7
  1006. Timer_NotBlank:
  1007.  
  1008. Timer_End:
  1009.         rts
  1010.  
  1011.  
  1012.  
  1013. NotTimerEvent:
  1014.         move.w  screenSecs(a5),blankTimer(a5)
  1015.  
  1016.         btst    #FLAGB_BLANK,qmouseFlag(a5)
  1017.         beq     NotTimer_End            ; screen not blank -- return
  1018.         bset    #POSTB_UNBLANK,d7
  1019.  
  1020. NotTimer_End:
  1021.         rts
  1022.  
  1023.  
  1024.  
  1025. MouseEvent:
  1026.         movem.l d1-d3/a0,-(sp)
  1027.  
  1028.         move.w  pointerSecs(a5),pointerTimer(a5)
  1029.  
  1030.         btst    #FLAGB_POINTEROFF,qmouseFlag(a5)
  1031.         beq     Mouse_NotPointer         ; pointer already on -- skip
  1032.         bsr     PointerOn
  1033. Mouse_NotPointer:
  1034.  
  1035.         cmpi.w  #1,mouseAccel(a5)
  1036.         ble     Mouse_NoAccel
  1037.         move.w  ie_Qualifier(a0),d0
  1038.         btst    #IEQUALIFIERB_RELATIVEMOUSE,d0
  1039.         beq     Mouse_NoAccel
  1040.         move.w  ie_X(a0),d0
  1041.         bsr     AccelMouse
  1042.         move.w  d0,ie_X(a0)
  1043.         move.w  ie_Y(a0),d0
  1044.         bsr     AccelMouse
  1045.         move.w  d0,ie_Y(a0)
  1046. Mouse_NoAccel:
  1047.  
  1048.         cmpi.w  #IECODE_LBUTTON,ie_Code(a0)
  1049.         bne     Mouse_NoClick
  1050.         bsr     CheckMouseClicks
  1051. Mouse_NoClick:
  1052.  
  1053.         cmpi.w  #IECODE_RBUTTON,ie_Code(a0)
  1054.         bne     Mouse_NoBack
  1055.         move.w  ie_Qualifier(a0),d0
  1056.         btst    #IEQUALIFIERB_LEFTBUTTON,d0
  1057.         beq     Mouse_NoBack
  1058.         bsr     WindowBack
  1059.         move.b  #IECLASS_NULL,ie_Class(a0)
  1060. Mouse_NoBack:
  1061.  
  1062.         cmpi.w  #IECODE_NOBUTTON,ie_Code(a0)
  1063.         bne     Mouse_NoSunMouse
  1064.         move.w  ie_Qualifier(a0),d0
  1065.         and.w   #IEQUALIFIER_LEFTBUTTON!IEQUALIFIER_MIDBUTTON!IEQUALIFIER_RBUTTON,d0
  1066.         bne     Mouse_NoSunMouse
  1067.         bsr     SunMouse
  1068. Mouse_NoSunMouse:
  1069.  
  1070. Mouse_End:
  1071.         movem.l (sp)+,d1-d3/a0
  1072.         rts
  1073.  
  1074.  
  1075.  
  1076. RawKeyEvent:
  1077.         bsr     SunMouse               ; make sure window is active
  1078.  
  1079.         move.w  ie_Qualifier(a0),d0
  1080.         btst    #IEQUALIFIERB_LCOMMAND,d0
  1081.         beq     RawKey_End
  1082.  
  1083.         btst    #FLAGB_NO_AMIGA_M,qmouseFlag(a5)
  1084.         bne     RawKey_NotShuffle
  1085.         cmpi.w  #RAW_M,ie_Code(a0)
  1086.         bne     RawKey_NotShuffle
  1087.         move.b  #IECLASS_NULL,ie_Class(a0)
  1088.         bset    #POSTB_SHUFFLE,d7
  1089. RawKey_NotShuffle:
  1090.  
  1091.         cmpi.w  #RAW_ESCAPE,ie_Code(a0)
  1092.         bne     RawKey_End
  1093.         move.b  #IECLASS_NULL,ie_Class(a0)
  1094.         btst    #IEQUALIFIERB_CONTROL,d0
  1095.         bne     RawKey_Quit
  1096.         bset    #POSTB_NEWCLI,d7
  1097.         bra     RawKey_End
  1098. RawKey_Quit:
  1099.         bset    #POSTB_QUIT,d7
  1100.  
  1101. RawKey_End:
  1102.         rts
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108. dosName          dc.b    'dos.library',0
  1109. graphicsName     dc.b    'graphics.library',0
  1110. layersName       dc.b    'layers.library',0
  1111. intuitionName    dc.b    'intuition.library',0
  1112. inputName        dc.b    'input.device',0
  1113.  
  1114. qmousePortName   dc.b    'QMouse 1.2 Port',0
  1115. nullName         dc.b    'NIL:',0
  1116. defaultCommand   dc.b    'NewCLI',0
  1117.  
  1118.  
  1119.  
  1120. blankNewScreen   dc.w    0,0,320,30,1
  1121.                  dc.b    0,0
  1122.                  dc.w    0
  1123.                  dc.w    CUSTOMSCREEN
  1124.                  dc.l    0,0,0,0
  1125.  
  1126. clockNewWindow   ds.w    0
  1127.                  dc.w    280,0
  1128.                  dc.w    CLOCK_WIDTH,10
  1129.                  dc.b    -1,2
  1130.                  dc.l    0
  1131.                  dc.l    SMART_REFRESH!NOCAREREFRESH
  1132.                  dc.l    0,0,0,0,0
  1133.                  dc.w    0,0
  1134.                  dc.w    0,0
  1135.                  dc.w    WBENCHSCREEN
  1136.  
  1137. clockBuffer      dc.b    '00:00',0
  1138.                  cnop    0,2
  1139.  
  1140. clockText        ds.w    0
  1141.                  dc.b    3,2
  1142.                  dc.b    RP_JAM2,0
  1143.                  dc.w    2,1
  1144.                  dc.l    0
  1145.                  dc.l    clockBuffer
  1146.                  dc.l    0
  1147.  
  1148.  
  1149.  
  1150.  
  1151.         IFD     MANX
  1152.  
  1153.         BSS     workarea,work_SIZEOF
  1154.  
  1155.         ENDC
  1156.  
  1157.         IFND    MANX
  1158.  
  1159.         SECTION uninit,BSS
  1160.  
  1161. workarea:
  1162.         ds.b    work_SIZEOF
  1163.  
  1164.         ENDC
  1165.  
  1166.  
  1167.         END
  1168.  
  1169.